﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta><style>/*<![CDATA[*/

table{border: 1px solid gray;}
td{border: 1px dotted gray;}
p{margin: 3px 0 3px 0; padding: 0;}
#ID_Footer{font-size: small; font-style: italic; text-align: right; margin-top: 4em; padding-top: 4px; border-top: 2px solid gray;}

/*]]>*/</style><title>01. ThinkPHP 3 介绍及安装</title></head><body>
<div><span style="font-family: 微软雅黑; font-size: 9pt; color: #000000; line-height: 140%">#</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"># ThinkPHP 3 介绍及安装</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"># </span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">讲师：赵桐正</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">微博：</span><a href="http://weibo.com/zhaotongzheng" style="font-family: 微软雅黑; font-size: 9pt; text-decoration: underline; color: #0000ff">http://weibo.com/zhaotongzheng</a></div>
<div><br /></div>
<div><span style="font-family: 微软雅黑; font-size: 16pt; font-weight: bold; line-height: 140%">本节课大纲：</span></div>
<div><br /></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; font-weight: bold; line-height: 140%">一、ThinkPHP的介绍 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//了解</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;MVC</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;M - Model 模型 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 工作：负责数据的操作</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;V &nbsp;- View &nbsp;视图（模板） &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 工作：负责前台页面显示</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;C &nbsp;- Controller 控制器（模块） 工作：描述功能</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;框架</span></div>
<div><br /></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; font-weight: bold; line-height: 140%">二、ThinkPHP的获取 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//了解</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;</span><a href="http://www.thinkphp.cn" style="font-family: 微软雅黑; font-size: 9pt; text-decoration: underline; color: #0000ff">http://www.thinkphp.cn</a></div>
<div><br /></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">三、</span><span style="font-family: 微软雅黑; font-size: 9pt; font-weight: bold; line-height: 140%">ThinkPHP核心文件介绍</span><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp;//了解 &nbsp; &nbsp; &nbsp; &nbsp;（ThinkPHP整个框架放入项目目录下）</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;├─ThinkPHP.php &nbsp; &nbsp; 框架入口文件 &nbsp; &nbsp; &nbsp; &nbsp; （而项目--项目目录是ThinkPHP目录的父目录，的入口文件是index.php)</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;├─Common 框架公共文件</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;├─Conf 框架配置文件</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;├─Extend 框架扩展目录</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;├─Lang 核心语言包目录</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;├─Lib 核心类库目录</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;│ &nbsp;├─Behavior 核心行为类库</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;│ &nbsp;├─Core 核心基类库</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;│ &nbsp;├─Driver 内置驱动</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;│ &nbsp;│ &nbsp;├─Cache 内置缓存驱动</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;│ &nbsp;│ &nbsp;├─Db 内置数据库驱动</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;│ &nbsp;│ &nbsp;├─TagLib 内置标签驱动</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;│ &nbsp;│ &nbsp;└─Template 内置模板引擎驱动</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;│ &nbsp;└─Template 内置模板引擎</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;└─Tpl 系统模板目录</span></div>
<div><br /></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">四、实验环境搭建 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//了解</span></div>
<div><br /></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">五、项目搭建 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//重点</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;#项目目录结构及说明：</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 微软雅黑; font-size: 9pt; font-weight: bold; line-height: 140%">Home 前台应用</span><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">文件夹</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;├─Common 项目公共文件目录</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;├─Conf 项目配置目录</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;├─Lang 项目语言目录</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 微软雅黑; font-size: 9pt; font-weight: bold; line-height: 140%">├─Lib </span><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">项目类库目录</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│ &nbsp;├─Action Action</span><span style="font-family: 微软雅黑; font-size: 9pt; font-weight: bold; line-height: 140%">类库目录</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│ &nbsp;├─Behavior 行为类库目录</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│ &nbsp;├─Model</span><span style="font-family: 微软雅黑; font-size: 9pt; font-weight: bold; line-height: 140%"> 模型类库目录</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│ &nbsp;└─Widget Widget类库目录</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 微软雅黑; font-size: 9pt; font-weight: bold; line-height: 140%">├─Runtime </span><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">项目运行时目录</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│ &nbsp;├─Cache 模板缓存目录</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│ &nbsp;├─Data 数据缓存目录</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│ &nbsp;├─Logs 日志文件目录</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│ &nbsp;└─Temp 临时缓存目录</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;└─Tpl </span><span style="font-family: 微软雅黑; font-size: 9pt; font-weight: bold; line-height: 140%">项目模板目录</span></div>
<div><br /></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">六、补充知识 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//了解</span></div>
<div><br /></div>
<div><br /></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">++++++++++++++++++++++++++++以下为Leo 注释++++++++++++++++++++++++++++++++++++++++++++</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">##视频教程wampserver版本为：wampserver2.2e-php5.3.13-httpd2.2.2-</span></div>
<div><br /></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">0. 在项目目录下放置ThinkPHP核心目录内容（以ThinkPHP为根的目录树，包括ThinkPHP文件夹本身）</span></div>
<div><br /></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">1. 在项目目录（即文档根目录下的thinkPHP目录）下，其主入口文件为</span><span style="font-family: 微软雅黑; font-size: 9pt; font-weight: bold; line-height: 140%">index.php</span><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">（需自建），在浏览器中运行后自动帮我们创建相应的文件夹</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;?php</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//1. 确定应用名称（前台应用）</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;define(&apos;</span><span style="font-family: 微软雅黑; font-size: 9pt; font-weight: bold; line-height: 140%">APP_NAME</span><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">&apos;, Home);</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//2. 确定应用路径</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;define(&apos;</span><span style="font-family: 微软雅黑; font-size: 9pt; font-weight: bold; line-height: 140%">APP_PATH</span><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">&apos;, ./Home/);</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//3. 引入核心文件</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;require &apos;</span><span style="font-family: 微软雅黑; font-size: 9pt; font-weight: bold; line-height: 140%">./ThinkPHP/ThinkPHP.php</span><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">&apos;;</span></div>
<div><br /></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">2. 再新建一个后台应用，新建一个admin.php如下。运行后自动创建后台应用目录结构。</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;?php</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//1. 确定应用名称（后台应用）</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;define(&apos;</span><span style="font-family: 微软雅黑; font-size: 9pt; font-weight: bold; line-height: 140%">APP_NAME</span><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">&apos;, Admin);</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//2. 确定应用路径</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;define(&apos;</span><span style="font-family: 微软雅黑; font-size: 9pt; font-weight: bold; line-height: 140%">APP_PATH</span><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">&apos;, ./Admin/);</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//3. 引入核心文件</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;require &apos;</span><span style="font-family: 微软雅黑; font-size: 9pt; font-weight: bold; line-height: 140%">./ThinkPHP/ThinkPHP.php</span><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">&apos;;</span></div>
<div><br /></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%">3. 前台和后台的公有目录，可以如下方式新建</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/项目目录/Public/ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//如javascript, CSS等公有代码</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/项目目录/Uploads/ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//如图片等</span></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div><script type="text/javascript" language="javascript" src="jquery.js"></script><script type="text/javascript" language="javascript" src="itemlink.js"></script></body></html>